Skip to content

Fix: Update RST File Based Tests#564

Merged
AlexanderLanin merged 8 commits into
eclipse-score:mainfrom
MaximilianSoerenPollak:MSP_update_rst_tests
May 29, 2026
Merged

Fix: Update RST File Based Tests#564
AlexanderLanin merged 8 commits into
eclipse-score:mainfrom
MaximilianSoerenPollak:MSP_update_rst_tests

Conversation

@MaximilianSoerenPollak
Copy link
Copy Markdown
Contributor

📌 Description

Current RST tests were quite hard to code directly and were error prone without having any insight.
This PR changes the RST tests to make them more explicit as well as making future expandability easier possible

🚨 Impact Analysis

  • This change does not violate any tool requirements and is covered by existing tool requirements
  • This change does not violate any design decisions
  • Otherwise I have created a ticket for new tool qualification

✅ Checklist

  • Added/updated documentation for new or changed features
  • Added/updated tests to cover the changes
  • Followed project coding standards and guidelines

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //src:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: 9c2f1d29-e434-43dd-970a-b335984fc416
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
    currently loading: src
WARNING: Target pattern parsing failed.
ERROR: Skipping '//src:license-check': no such target '//src:license-check': target 'license-check' not declared in package 'src' defined by /home/runner/work/docs-as-code/docs-as-code/src/BUILD
ERROR: no such target '//src:license-check': target 'license-check' not declared in package 'src' defined by /home/runner/work/docs-as-code/docs-as-code/src/BUILD
INFO: Elapsed time: 5.312s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

@github-actions
Copy link
Copy Markdown

The created documentation from the pull request is available at: docu-html

@MaximilianSoerenPollak MaximilianSoerenPollak changed the title Msp update rst tests Feat: Update RST File Based Tests May 28, 2026
@MaximilianSoerenPollak MaximilianSoerenPollak changed the title Feat: Update RST File Based Tests Fix: Update RST File Based Tests May 28, 2026
Comment thread src/extensions/score_metamodel/tests/test_rules_file_based.py Outdated
Comment thread src/extensions/score_metamodel/tests/test_rules_file_based.py Outdated
Comment thread src/extensions/score_metamodel/tests/test_rules_file_based.py Outdated
Comment thread src/extensions/score_metamodel/tests/test_rules_file_based.py Outdated
Comment thread src/extensions/score_metamodel/tests/test_rules_file_based.py
@AlexanderLanin
Copy link
Copy Markdown
Member

AI-assisted review (Claude):

Critical: 0 | Important: 1 | Suggestions: 3

Overall this is a clear improvement: the new #EXPECT[+N] syntax makes test intent explicit, the line-offset validation catches malformed test files before Sphinx runs, and replacing os.chdir with monkeypatch.chdir is the right call for test isolation. The refactoring into extract_test_data + group_test_data is clean.

Important

  • Removing the score_metamodel filter on warnings widens the pool to all Sphinx warnings. The position filter protects EXPECT checks, but EXPECT-NOT checks could spuriously fail if Sphinx emits an unrelated warning on the same line as a need. Needs a clear justification (inline comment or PR description). See inline comment on line 295.

Suggestions

  • DOCS_DIR and logger are dead code — neither is referenced after this PR. Drop both (line 25, line 32).
  • if not rst_data_raw is an unreachable branch — RstData is always truthy and extract_test_data never returns None (line 270).
  • Missing space in the offset == 1 error message: "...and need.Please add..." (line 166).
  • Commented-out debug print has a syntax error: for w warningsfor w in warnings (line 299).

@MaximilianSoerenPollak
Copy link
Copy Markdown
Contributor Author

@AlexanderLanin I in cooperated some of the Review comments, have another look if you can.

to be emitted and checked for 2 lines underneath

There is multiple things that are not allowed for example, you need to have
a new line between the EXPECT/-NOT and the need that it refers to
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a new line between the EXPECT/-NOT and the need.
If that is not the case, then our parser sees it correctly (as we just filter for '.. ' and '::') but sphinx-needs or more precisely docutils thinks it is normal text and doesn't actually generate the need itself.
Therefore we have a miss match of what we see and what sphinx sees. This is not fixable on our side (making the need when sphinx doesn't see it). So we have to enforce (lightly) that there is a new line.

specified after the EXPECT/EXPECT-NOT statement.

This message needs a '[+x]'offset after the 'EXPECT/-NOT' that should point to the need
that should (not) emit the warning.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to practically always be [+2]. So it feels more like unnecessary boilerplate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is currently cause we only have 1 EXPECT there. If we had 2 or more it would be `
EXPECT[+3]: ...
EXPECT[+2]: ...

etc.
It truly is only an offset that EXACTLY tells us where they want the warning to be.
This way we can also safeguard a bit against sphinx not seeing a need but we do.

AlexanderLanin
AlexanderLanin previously approved these changes May 29, 2026

RST_FILES = [str(f.relative_to(RST_DIR)) for f in Path(RST_DIR).rglob("*.rst")]

logger = get_logger(__file__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted review (Claude):

logger is imported and instantiated here but never called anywhere in this file. Dead code — drop both lines.

Suggested change
logger = get_logger(__file__)

Copy link
Copy Markdown
Member

@AlexanderLanin AlexanderLanin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted review (Claude):

Critical: 0 | Important: 0 | Suggestions: 1


Good shape. The previous round's concerns are all addressed:

  • Dead DOCS_DIR removed ✅
  • if not rst_data_raw dead guard removed ✅
  • Missing space in the offset-1 error message fixed ✅
  • Commented-out debug print syntax error fixed ✅
  • Warning filter broadening: the comment on line 302–304 explains the rationale. Acceptable. ✅
  • monkeypatch.chdir replacing os.chdir

One small thing remaining: logger (lines 22 + 29) is imported and instantiated but never called. See inline comment.

@AlexanderLanin AlexanderLanin merged commit e74b1b4 into eclipse-score:main May 29, 2026
11 of 13 checks passed
@a-zw a-zw mentioned this pull request May 29, 2026
a-zw added a commit to etas-contrib/score_docs-as-code that referenced this pull request May 29, 2026
Added tests in eclipse-score#558 and in parallel modified tests in eclipse-score#564.
That created a conflict which only became obvious once both were merged
to main.
MaximilianSoerenPollak pushed a commit that referenced this pull request May 29, 2026
Added tests in #558 and in parallel modified tests in #564.
That created a conflict which only became obvious once both were merged
to main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants